package com.efesco.crm.crm;

import java.text.SimpleDateFormat;

import com.bstek.dorado.data.*;
import com.bstek.dorado.data.db.SqlDataset;
import com.bstek.dorado.common.*;
import com.efesco.common.CommUtil;

/**
 * materialQuery_datasetResultListener
 */
public class materialQuery_datasetResultListener extends AbstractDatasetListener {
  public boolean beforeLoadData(Dataset dataset)
     throws Exception {
	  SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
	  SqlDataset ds = (SqlDataset) dataset;
	  String sql="select e.*,decode(eoop.employee_type,null,0,eoop.employee_type) as employee_type,sc.COMPANY_CHINESE_NAME from " +
	  		" S_EM_CARD_REGRESS ecr,s_employee e,s_employee_on_off_post eoop,s_single_company sc " +
	  		" where e.employee_id=eoop.employee_id(+) and e.single_company_id=sc.single_company_id(+) and e.employee_id=ecr.employee_id" +
	  		" and ecr.type="+ds.parameters().getString("in_char_service_id")+"";

	  if(ds.parameters().getInt("is_material_all")>0){
		  sql+=" and ecr.is_material_all="+ds.parameters().getInt("is_material_all");
	  }
	  
	  ds.setSql(sql);
	  
    return true;
  }

}
